Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using XDG_RUNTIME_DIR #143

Merged
merged 1 commit into from
Jun 13, 2019
Merged

Conversation

takluyver
Copy link
Member

After years of trying to make this work, I've reluctantly come to the conclusion that XDG_RUNTIME_DIR is, for us, more trouble than it's worth.

Three problems in particular have led to this:

  1. When Jupyter runs as a server, e.g. with screen or nohup, XDG_RUNTIME_DIR can be deleted from under us if the user logs out. I haven't found any good way to prevent this.
  2. The spec allows files to be automatically cleaned up after a few hours. In theory this can be prevented by setting the sticky bit, but it's not clear where it needs to be set, and we can't be sure that all systems actually respect that.
  3. Sometimes the environment variable is automatically carried over from a context where it's accurate to a context where it's not. It's definitely not the only environment variable for which this can happen,
    but since it's set at login by many modern Linux systems, it's an obvious source of problems.

Set against this, the benefits of XDG_RUNTIME_DIR:

  • The system should ensure that it is readable and writable only to the user who owns it. It doesn't save us any complexity, because we still try to make the same guarantees on platforms without XDG_RUNTIME_DIR, but it's nice to have an extra backstop against oversights by us or by our users.
  • It's reset on each boot, so if kernels or servers crash and don't clean up their connection files, those files don't last forever. It's nice to have, but again, we need to cope with leftover files for other
    platforms.
  • You can reliably use XDG_RUNTIME_DIR for objects like named pipes and Unix sockets, because it's guaranteed not to be on NFS. We do have an option to use Unix sockets for ZMQ connections, but as far as I know, it's rarely used. We can find other ways to use it for that specific purpose if necessary.

After years of trying to make this work, I've reluctantly come to the
conclusion that XDG_RUNTIME_DIR is, for us, more trouble than it's
worth.

Three problems in particular have led to this:

1. When Jupyter runs as a server, e.g. with screen or nohup,
XDG_RUNTIME_DIR can be deleted from under us if the user logs out. I
haven't found any good way to prevent this.
2. The spec allows files to be automatically cleaned up after a few
hours. In theory this can be prevented by setting the sticky bit, but
it's not clear where it needs to be set, and we can't be sure that all
systems actually respect that.
3. Sometimes the environment variable is automatically carried over from
a context where it's accurate to a context where it's not. It's
definitely not the only environment variable for which this can happen,
but since it's set at login by many modern Linux systems, it's an
obvious source of problems.

Set against this, the benefits of XDG_RUNTIME_DIR:

- The system should ensure that it is readable and writable only to the
user who owns it. It doesn't save us any complexity, because we still
try to make the same guarantees on platforms without XDG_RUNTIME_DIR,
but it's nice to have an extra backstop against oversights by us or by
our users.
- It's reset on each boot, so if kernels or servers crash and don't
clean up their connection files, those files don't last forever. It's
nice to have, but again, we need to cope with leftover files for other
platforms.
- You can reliably use XDG_RUNTIME_DIR for objects like named pipes and
Unix sockets, because it's guaranteed not to be on NFS. We do have an
option to use Unix sockets for ZMQ connections, but as far as I know,
it's rarely used. We can find other ways to use it for that specific
purpose if necessary.
@takluyver
Copy link
Member Author

@minrk I think this would let us simplify some code, avoid some weird bugs, and generally bring things on Linux more in line with other platforms. I like the idea of XDG_RUNTIME_DIR, but in practice it's a pain to work with.

@rgbkrk
Copy link
Member

rgbkrk commented Jun 14, 2019

Hurrah!

cc @captainsafia who added support for XDG_RUNTIME_DIR to the nteract js version of this package

cmd-ntrf added a commit to ComputeCanada/puppet-jupyterhub that referenced this pull request Aug 30, 2023
Since Jun 13, 2019, by PR jupyter/jupyter_core#143,
XDG_RUNTIME_DIR is no longer used by Jupyter to determine where to
store its runtime file. If we leave JUPYTER_RUNTIME_DIR unset,
the runtime files are stored in the user's home, which can cause
performance issue when the home is on a network filesystem like NFS or Lustre.
cmd-ntrf added a commit to cmd-ntrf/jupyter that referenced this pull request Aug 30, 2023
Since [jupyter_core PR jupyter#143](jupyter/jupyter_core#143),
XDG_RUNTIME_DIR is no longer used to set Jupyter runtime dir, and the
default on all platforms is `(data_dir)/runtime`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants